package com.yonyou.pmclouds.repeatwork.process;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.project.entity.ProjectConst;
import com.yonyou.pmclouds.project.entity.ProjectVO;
import com.yonyou.pmclouds.project.rmiitf.ProjectSimpleQuery;
import com.yonyou.pmclouds.repeatwork.entity.RepeatWorkVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 校验当前项目是否有停工单：检查当前是否停工？
 */
@Component
public class CheckWorkStop4ProjectProcessor implements SingleProcessor<RepeatWorkVO> {
    @Autowired
    private ProjectSimpleQuery projectSimpleQuery;

    @Override
    public void process(RepeatWorkVO vo, RepeatWorkVO orig) throws BusinessException{
        String pk_project = vo.getPkProject();
        ProjectVO projectVO = projectSimpleQuery.queryProject(pk_project);

        if(projectVO.getProjectState() != ProjectConst.STATE_STOP)
            throw new BusinessException("项目未停工，不需要进行复工");
    }
}
